package com.itcam.reflect_.msb03;

import java.lang.annotation.Annotation;

/**
 * Author:Cammy.Wu
 * Date:2024-05-22
 * Description:
 */
/**
 *
 */
public class Test04 {
    public static void main(String[] args) {
        // 获取字节码信息
        Class cls = Student.class;

        // 获取运行时类的接口
        Class[] interfaces = cls.getInterfaces();
        for (Class anInterface : interfaces) {
            System.out.println("anInterface = " + anInterface);
        }

        // 得到父类的接口
        // 先得到父类的字节码信息
        Class superclass = cls.getSuperclass();

        // 得到接口
        Class[] interfaces1 = superclass.getInterfaces();
        for (Class sic : interfaces1) {
            System.out.println("sic = " + sic);
        }

        // 获取运行时类所在的包
        Package clsPackage = cls.getPackage();
        System.out.println("clsPackage = " + clsPackage);
        System.out.println(clsPackage.getName());

        // 获取运行类的注解
        Annotation[] annotations = cls.getAnnotations();
        for (Annotation annotation : annotations) {
            System.out.println("annotation = " + annotation);
        }
    }
}
